package com.bdqn.ch06SL.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;

/**
 * 定义包含增强方法的JavaBean
 * 通过注解实现异常抛出增强
 */
public class ErrorLogger {
    private static final Logger looger  = Logger.getLogger(ErrorLogger.class);

    @AfterThrowing(pointcut = "execution(* com.bdqn.ch06SL.service.UserService.*(..))", throwing = "e")
    public void afterThrowing(JoinPoint jp, RuntimeException e) {
        looger.error(jp.getSignature().getName() + " 方法发生异常：" + e);
    }
}
